home *** CD-ROM | disk | FTP | other *** search
- ;;;;
- ;;;; Script to test the "busy" command.
- ;;;;
- (set! *load-path* (cons ".." *load-path*))
- (require "blt")
-
- ;;;;
- ;;;; General widget class resource attributes
- ;;;;
- (option 'add "*Button.padX" 10)
- (option 'add "*Button.padY" 2)
- (option 'add "*Scale.relief" 'sunken)
- (option 'add "*Scale.orient" 'horizontal)
- (option 'add "*Entry.relief" 'sunken)
-
-
- (define activeBg 'red)
- (define normalBg 'springgreen)
- (define bitmapFg 'blue)
- (define bitmapBg 'green)
-
- (let ((visual (winfo 'screenvisual *root*)))
- (when (or (eq? visual 'staticgray) (eq? visual 'grayscale))
- (set! activeBg black)
- (set! normalBg white)
- (set! bitmapFg black)
- (set! bitmapBg white)))
-
- ;;;;
- ;;;; Instance specific widget options
- ;;;;
- (option 'add "STk.top.relief" 'sunken)
- (option 'add "STk.top.borderWidth" 4)
- (option 'add "STk.top.background" normalBg)
- (option 'add "STk.b1.text" "Test")
- (option 'add "STk.b2.text" "Quit")
- (option 'add "STk.b3.text" "New button")
- (option 'add "STk.b4.text" "Hold")
- (option 'add "STk.b4.background" activeBg)
- (option 'add "STk.b4.foreground" normalBg)
- (option 'add "STk.b5.text" "Release")
- (option 'add "STk.b5.background" normalBg)
- (option 'add "STk.b5.foreground" activeBg)
-
- ;;;;
- ;;;; This never gets used; it's reset by the Animate proc. It's
- ;;;; here to just demonstrate how to set busy window options via
- ;;;; the host window path name
- ;;;;
- (option 'add "STk.top.busyCursor" 'bogosity)
-
- ;;;;
- ;;;; Initialize a list bitmap file names which make up the animated
- ;;;; fish cursor. The bitmap mask files have a "m" appended to them.
- ;;;;
- (define bitmaps '(fc_left fc_left1 fc_mid fc_right1 fc_right))
-
- ;;;;
- ;;;; Counter for new buttons created by the "New button" button
- ;;;;
- (define numWin 0)
- ;;;;
- ;;;; Current index into the bitmap list. Indicates the current cursor.
- ;;;; If -1, indicates to stop animating the cursor.
- ;;;;
- (define cnt -1)
-
- ;;;;
- ;;;; Create two frames. The top frame will be the host window for the
- ;;;; busy window. It'll contain widgets to test the effectiveness of
- ;;;; the busy window. The bottom frame will contain buttons to
- ;;;; control the testing.
- ;;;;
- (frame '.top)
- (frame '.bottom)
-
- ;;;;
- ;;;; Create some widgets to test the busy window and its cursor
- ;;;;
- (button '.b1 :command (lambda () (display "Not busy.\n")))
- (button '.b2 :command (lambda () (destroy *root*)))
- (entry '.e1)
- (scale '.s1)
-
- ;;;;
- ;;;; The following buttons sit in the lower frame to control the demo
- ;;;;
- (button '.b3 :command (lambda ()
- (set! numWin (+ numWin 1))
- (let* ((name (format #f "button#~A" numWin))
- (widg (& .top "." name)))
- (button widg
- :text name
- :command (lambda ()
- (format #t "I am ~A\n" name)))
- (pack widg :expand #t :padx 10 :pady 10))))
- (button '.b4 :command (lambda ()
- (blt_busy '.top :in *root*)
- (focus "")
- (when (< cnt 0)
- (tk-set! .top :bg activeBg)
- (set! cnt 0)
- (Animate .top))))
- (button '.b5 :command (lambda ()
- (catch (blt_busy 'release '.top))
- (set! cnt -1)
- (tk-set! .top :bg normalBg)))
-
- ;;;;
- ;;;; Notice that the widgets packed in .top and .bottom are not their children
- ;;;;
- (pack .b1 .e1 .s1 .b2 :in .top :expand #t :padx 10 :pady 10)
- (pack .b3 .b4 .b5 :in .bottom :expand #t :padx 10 :pady 10)
-
-
- ;;;;
- ;;;; Finally, realize and map the top level window
- ;;;;
- (pack .top .bottom :expand #t)
-
- ;;;;
- ;;;; Simple cursor animation routine: Uses the "after" command to
- ;;;; circulate through a list of cursors every 0.075 seconds. The
- ;;;; first pass through the cursor list may appear sluggish because
- ;;;; the bitmaps have to be read from the disk. Tk's cursor cache
- ;;;; takes care of it afterwards.
- ;;;;
- (define (Animate w)
- (if (>= cnt 0)
- (let* ((name (list-ref bitmaps cnt))
- (src (format #f "@bitmaps/~A" name))
- (mask (format #f "bitmaps/~Am" name)))
- (blt_busy 'configure w :cursor (format #f "~A ~A ~A ~A"
- src mask bitmapFg bitmapBg))
- (set! cnt (modulo (+ cnt 1) 5))
- (after 75 (lambda () (Animate w))))))
-
-
-
- ;;;;
- ;;;; For testing purposes allow the top level window to be resized
- ;;;;
- (wm 'min *root* 0 0)
-
- ;;;;
- ;;;; If the "raise" window command exists, force the demo to stay raised
- ;;;;
- (if (symbol-bound? 'raise)
- (bind *root* "<Visibility>" '(raise "%W")))
-
-